import React from "react";
import './index.scss'

import { getCurrentCity } from "../../utils";

import NavHeader from '../../components/NavBar'

const BMap = window.BMap

class Map extends React.Component {

  async componentDidMount() {
    const { name } = await getCurrentCity()
    console.log(name)
    var map = new BMap.Map("container");
    // map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
    var myGeo = new BMap.Geocoder();
    myGeo.getPoint(name,
      async point => {
        if (point) {
          map.centerAndZoom(point, 11);
          // map.addOverlay(new BMap.Marker(point));
        }
      },
      name);
  }

  render() {
    return (
      <div className="map-container">
        <NavHeader children={'地图定位'}></NavHeader>
        <div id="container" className="container" />
      </div>
    )
  }
}

export default Map
